package com.hkbigdata.springbootmybatis.controller;

import com.hkbigdata.springbootmybatis.bean.Department;
import com.hkbigdata.springbootmybatis.mapper.DepartmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liuanbo
 * @creat 2024-11-01-10:02
 * @see 2194550857@qq.com
 */
@RestController
public class DepartmentController {
    @Autowired
    DepartmentMapper departmentMapper;


    @GetMapping("/dept/{id}")
    public Department findById(@PathVariable("id") Integer id) {
        Department department = departmentMapper.findById(id);

        return department;
    }

    @GetMapping("/dept/insert")
    public String insertdept(Department department) {
        int i = departmentMapper.insertDept(department);
        return "影响的行数：" + i;
    }

    @GetMapping("/dept/update")
    public String updatedept(Department department) {
        int i = departmentMapper.updateDept(department);
        return "影响的行数：" + i;
    }

    @GetMapping("/dept/delete/{id}")
    public String deletedept(@PathVariable("id") Integer id) {
        int i = departmentMapper.deleteDept(id);
        return "影响的行数：" + i;
    }


}
